.Modal,
.Popup {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 100%;
  z-index: @zindex-modal;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 0;
}

.Modal {
  &.active {
    .Modal-dialog {
      opacity: @modal-show-opacity;
      transform: @modal-show-transform;
    }
  }
}

.Modal-dialog {
  position: relative;
  z-index: @zindex-modal;
  width: @modal-width;
  border-radius: @modal-border-radius;
  background: @modal-bg;
  box-shadow: @modal-box-shadow;
  opacity: @modal-opacity;
  transition: @modal-transition;
  transform: @modal-fade-transform;
}

@media (max-width: 320px) {
  .Modal-dialog {
    width: 300px;
  }
}

.Modal-header {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: @modal-header-padding;
}

.Modal-title {
  flex: 1;
  margin: @modal-title-margin;
  color: @modal-title-color;
  font-size: @modal-title-font-size;
  font-weight: @modal-title-font-weight;
}

.Modal-close {
  margin: -@icon-button-lg-padding;
  color: @modal-close-color;
}

.Modal-footer {
  display: flex;
}

.Modal-footer--h {
  padding: @modal-footer-x-padding;

  .Btn {
    flex: 1 1 auto;
  }
  .Btn + .Btn {
    margin-left: @modal-btn-x-spacing;
  }
}

.Modal-footer--v {
  flex-direction: column;
  padding-top: @modal-footer-y-padding-top;

  .Btn {
    padding: @modal-btn-y-padding 12px;
    border: 0;
    border-top: @modal-btn-y-border-width solid @modal-btn-y-border-color;
    border-radius: 0;
    background: @modal-btn-y-bg;
    color: @modal-btn-y-color;
    font-weight: @modal-btn-y-font-weight;

    &:last-child {
      border-radius: 0 0 @modal-border-radius @modal-border-radius;
    }
  }
  .Btn--primary {
    color: @modal-btn-y-primary-color;
  }
}

/* Popup */
.Popup {
  align-items: flex-end;

  &.active {
    .Popup-dialog {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }
}

.Popup-dialog {
  position: relative;
  z-index: @zindex-popup;
  overflow: hidden;
  width: 100%;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius: @popup-border-radius;
  background: @popup-bg;
  box-shadow: @popup-box-shadow;
  opacity: 0;
  transform: translate3d(0, 100%, 0);
  transition: 0.3s;
}

.Popup-header {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: @popup-header-padding;
}

.Popup-title {
  flex: 1;
  margin: @popup-title-margin;
  color: @popup-title-color;
  font-size: @popup-title-font-size;
}

.Popup-close {
  margin: -@icon-button-lg-padding;
  color: @popup-close-color;
}

.Popup-body {
  &.overflow {
    max-height: 300px;
    max-height: @popup-max-height;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.Popup-footer {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: @popup-footer-padding;
  background: @popup-footer-bg;
  box-shadow: @popup-footer-box-shadow;

  .Btn + .Btn {
    margin-top: @popup-btn-x-spacing;
  }
}

/* Confirm */
.Confirm {
  text-align: center;

  .Modal-body {
    color: @confirm-color;
    padding: @confirm-body-padding;
  }
}

.S--modalOpen,
.S--modalOpen .MessageContainer > .PullToRefresh {
  overflow: hidden;
}

.S--wide {
  .Popup {
    align-items: center;
  }
  .Popup-dialog {
    width: @popup-wide-width;
    border-radius: @modal-border-radius;
  }
}
